package com.suixinsanren.design.observer.demo03;

import org.junit.Before;
import org.junit.Test;

public class WeatherDataDisplayTestDrive {

    private WeatherData weatherData;

    @Before
    public void init() {
        weatherData = new WeatherData();
    }

    @Test
    public void test() {
        AverageDisplay averageDisplay = new AverageDisplay();
        StatisticsDisplay statisticsDisplay = new StatisticsDisplay();

        weatherData.update(38, 20, 30);

        weatherData.registerObserver(averageDisplay);
        weatherData.registerObserver(statisticsDisplay);

        weatherData.update(20, 30, 40);

        weatherData.removeObserver(averageDisplay);

        weatherData.update(10, 0, 0);
    }

}
